package cn.com.queue;
/**
 * @author liufl
 * @version 创建时间：2017年7月19日 上午8:57:48
 * 类说明
 */
import java.util.Date;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import cn.com.entity.UserOrderDTO;

/** 
 * 发送短信服务类 
 * @author cuiran 
 * @version TODO 
 */  
public class SendMsgExecutor {  
//	private static Log log = LogFactory.getLog(SendMsgExecutor.class);
    private static int threadNumber = 2;  
    final static ExecutorService exec = Executors.newFixedThreadPool(threadNumber);  
      
    public static void start() {  
         for(int i=0;i<threadNumber;i++){  
             exec.submit(new SendMsgThread(i));  
         }  
    }  
    public void stop(){  
        exec.shutdown();  
    }  
    
    public static void testPut(){
    	for (int i = 0; i <5; i++) {
    		UserOrderDTO msg = new UserOrderDTO();
    		msg.setId(Long.valueOf(i+""));
    		msg.setBirthday(new Date());
    		msg.setUsername((int)(Math.random()*100)+"_hello");
    		SendMsgQueue.putMessage(msg);
    	}
    }
    public static void main(String[] args) {
    	SendMsgExecutor.testPut();
    	SendMsgExecutor.start();
	}
}  